Working with arrays

 

Here you can learn how to work with arrays.

Read the following steps and learn.

 

 

1. How to summarise some variables to one array

Just use this command:

 

testarray = [Variable1,Variable2,Variable3]

 

Testarray is now the array with the variables.

 

 

 

2. How to add a variable to an existing array

Just use the command from step 1 and add this command:

 

+ [Variable4,Variable5]

 

It should look like this:

testarray = [Variable1,Variable2,Variable3] + [Variable4,Variable5]

 

 

 

3. How to delete a variable from an existing array

This is the same procedure as step 2 but this time you must set a minus instead of plus

 

- [Variable2,Variable3]

 

It should look like this:

testarray = [Variable1,Variable2,Variable3] - [Variable2,Variable3]

 

 

 

4. How to count all variables from an existing array

Just use this command

 

NumberOfAll = Count Testarray

 

NumberOfAll is the variable where the counted number of all variables in the array will be saved.

Count is the command to count the variables, in this example from the array Testarray

 

 

 

5. How to count all living soldiers in an existing array

Just use this command

 

number = "Alive _x" Count Testarray

 

 

6. And here is an example

 

This script saves all soldiers in an array and you will get a message

if all soldiers are dead, instead of a message you can use another command.

 

soldierarray = [s1,s2,s3,s4,s5,s6]

#Start
~1
number = "Alive _x" Count soldierarray

if (number == 0) then {hint "They are all dead"; goto "End";}

goto "Start";

#End

 

 

 

This project will continue in the future...